/*
	ahci.h

	contains ahci driver headers and shizz

	Author: Aidan Goddard 27/1/14
*/

#ifndef AHCI_H_INCLUDED
#define AHCI_H_INCLUDED


#include"../general/driver_error_codes.h"
#include"../../klib/headers/ktypes.h"
#include"../../klib/headers/klib_PCIE.h"
#include"../../klib/headers/klib_IRQ_control.h"
#include"../../klib/headers/klib_proc_threads.h"
#include"../../klib/headers/klib_ACPI_tables.h"
#include"../../klib/headers/klib_system_resources.h"
#include"../../kernel/headers/system_error.h"
#include"../../kernel/headers/bakery_lock.h"
#include"../../kernel/headers/scheduler_tables.h"
#include"../ACDM/ACDM_mod.h"

#define DEBUG

#ifdef DEBUG
#include"../../setup/headers/printf.h"
#endif

#define AHCI_INIT_SUCCESS				0
#define AHCI_INIT_FAIL_NO_DEVICES		0xffffffff
#define AHCI_INIT_FAIL_NO_BOOT			0xfffffffe
#define AHCI_INIT_FAIL_NO_ISR			0xfffffffd
#define AHCI_INIT_FAIL_NO_IRQ			0xfffffffc
#define AHCI_INIT_FAIL_BOOT_NOT_PRESENT	0xfffffffb

#define AHCI_READ_SUCCESS				0
#define AHCI_BOOT_READ_DISABLED			0xffffffff

#define FAT32_SUCCESS					0
#define FAT32_BOOT_READ_DISABLED		0xffffffff
#define FAT32_DISK_READ_ERROR			0xfffffffe
#define FAT32_IS_FAT_12					0xfffffffd
#define FAT32_IS_FAT_16					0xfffffffc
#define FAT32_CLUSTER_TOO_LARGE			0xfffffffb
#define FAT32_DIR_CHANGE				0xfffffffa
#define FAT32_NO_PATH					0xfffffff9



// AHCI level stuff
uint32_t AHCI_INIT();
uint32_t AHCI_DROP();
uint32_t AHCI_BOOT_READ(char *buffer, uint64_t sec_start, uint16_t sec_count);

// filesystem stuff
uint32_t FAT32_INIT();
uint32_t BootGetDirCount(char *path, uint32_t *dirs_length);
uint32_t BootGetDirs(char *path, char *dirs, uint32_t dirs_length);
uint32_t BootReadFile(char *path, char *buffer, uint32_t start, uint32_t length);



#endif
